//
// Created by steven on 2017/2/24.
// Copyright (c) 2017 steven. All rights reserved.
//

#import "GMOrderTableViewCell.h"


@implementation GMOrderTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupMainView];
    }

    return self;
}

- (void)setupMainView {
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    [self addSubview:self.iconImageView];
    [self addSubview:self.countTitleLabel];
    [self addSubview:self.countLabel];
    [self addSubview:self.dateLabel];
    [self addSubview:self.costLabel];

    // icon image view
    [self.iconImageView autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
    [self.iconImageView autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:45];
    [self.iconImageView autoSetDimensionsToSize:CGSizeMake(30, 50)];
    
    // count title label
    [self.countTitleLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.iconImageView];
    [self.countTitleLabel autoPinEdge:ALEdgeLeading toEdge:ALEdgeTrailing ofView:self.iconImageView withOffset:40];
    
    // count label
    [self.countLabel autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.countTitleLabel];
    [self.countLabel autoPinEdge:ALEdgeLeading toEdge:ALEdgeTrailing ofView:self.countTitleLabel withOffset:8];
    
    // date label
    [self.dateLabel autoPinEdge:ALEdgeLeading toEdge:ALEdgeTrailing ofView:self.iconImageView withOffset:40];
    [self.dateLabel autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.iconImageView];

    // cost label
    [self.costLabel autoPinEdge:ALEdgeLeading toEdge:ALEdgeTrailing ofView:self.iconImageView withOffset:40];
    [self.costLabel autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.iconImageView];
}

- (UIImageView *)iconImageView {
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guard-icon"]];
    }
    
    return _iconImageView;
}

- (UILabel *)countTitleLabel {
    if (!_countTitleLabel) {
        _countTitleLabel = [[UILabel alloc] init];
        _countTitleLabel.text = @"守卫侠个数";
        _countTitleLabel.font = [UIFont systemFontOfSize:16];
    }
    
    return _countTitleLabel;
}

- (UILabel *)countLabel {
    if (!_countLabel) {
        _countLabel = [[UILabel alloc] init];
        _countLabel.font = [UIFont systemFontOfSize:24];
    }
    
    return _countLabel;
}

- (UILabel *)dateLabel {
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.textColor = [UIColor grayColor];
        _dateLabel.font = [UIFont systemFontOfSize:10];
    }
    return _dateLabel;
}

- (UILabel *)costLabel {
    if (!_costLabel) {
        _costLabel = [[UILabel alloc] init];
        _costLabel.textColor = [UIColor grayColor];
        _costLabel.font = [UIFont systemFontOfSize:10];
    }
    return _costLabel;
}

@end
